package cz.apnetis.gwt.client;

import com.google.gwt.user.client.ui.Widget;

/** This interface must implements data provider for table which want to edit
 * table view
 * @author Lukas "benzin" Benda <a href="mailto:bendal@apnet.cz">bendal@apnet.cz</a>
 * @since Oct 2, 2010
 */
public interface TableModel {

  /** Return names of columns. */
  String[] getColumnNames();

  /** Return localized name of columns.
   * @param columnName name of column
   * @return localized name of column. if isn't localized then can return given column name
   *         or ??? columnName ??? if must be localized
   */
  String getColumnNameI18n(final String columnName);

  /** Count of row in table */
  int getRowCount();

  /** Method which return widget for field
   * @param row row for which is widget need
   * @param colName name of column which must be show
   * @return widget (never null) which must be insert to table field.
   */
  Widget getFieldWidget(int row, String colName);

  /** Method which return txt representation of position in table result */
  String getResultPosition();

  /** Inform if table model have some previous page */
  boolean hasPrevious();
  /** Inform if table model have some next page */
  boolean hasNext();

  /** Method which load previous data for table, and after it call repaint of table
   * @param repaintAfter object which is repaint after this method end
   */
  void loadPrevious(Repaintable reapintAfter);
  /** Method which load next data for table, and after it call repaint of table
   * @param repaintAfter object which is repaint after this method end
   */
  void loadNext(Repaintable reapintAfter);
}
